Having covered a few key concepts of working with the browser window module, we're still left with
an enormous amount of properties, methods and configuration options to help create exactly what you
need in this lesson, then let's go over some important and interesting properties and methods of this
module.
First up, configuration options.
When we create a new browser window instance, we can define a number of different options to customize
it with all of these here, for example, the minimum width and minimum height at the moment with only
an initial with and height specified.
When I resize the app window main window, I can keep going to the point where this no longer makes
any sense.
If a user ever requires a window to be this small, it might as well be minimized as it's no longer
usable.
This is where Menwith and Monheit comes to the rescue back in mind.
Yes, we can set on this main window constructor a minimum worth of, say, three hundred and Monheit
of 150.
These values will of course, depend on the content of your own app Save.
Resized that window back down as before.
And it sticks at those minimum dimensions, we can do the same for maximum worth and maximum height,
but this is less of a problem as the user will always be restricted by the available screen space.
Again, should the content specific to your app require the maximum size to be limited?
The option is there.
Equally, we can change the default window behavior like disabling resizing of the window, the ability
to move it around, or even minimizing and maximizing it.
The list goes on.
There's an option for pretty much anything you would ever want to change on a window.
Next, we get to the instance events for the browser window, much like the app instance we looked at
first.
This allows us to listen for key events on the window instance, for example, focus and blur, like
the app instance, but specific to a given browser window.
I'll demonstrate.
Add a second window sic window, duplicate the main window, but assign the browser window instance
to that set window variable change that I mentioned a bit to differentiate them.
Load index dot html into SEC window.
And get rid of the dev tools with lastly, a listener to unseat this new window instance when it's closed.
There with that done all add focus lessness for each window, main window on focus, pass a callback
which locks out main window focused.
Same for Secondo.
Second window focused.
Save this.
Those two windows gets created and now in the terminal, I'll bring it over so we can observe, we see
a message second window focused, which happened when the app was launched.
Click back into that second window.
We see another similar log, meaning this window came into focus, click the main window and that fire
its focus event and so on.
So window specific, very importantly, note that the app instance will fire its browser window focus
event.
Every time one of these windows come into focus.
I'll add that listener app on browser window focus, which, if we look at the naming here, is essentially
a trigger for any of these focus events from a browser window logging out app focused save.
There, the happenstance fires its focus event, not caring which window came into focus, and with
that being the second window, we see it's log also with this happening every time a browser window
is focused.
See this by switching to the main window, the app event fires, then the browser windows back to second
window and so on.
We also have the usual events like show, hide, etc. all very self-explanatory and a bit further down.
Static methods, these being methods unrelated to a specific window, but rather useful utilities for
managing and working with individual window instances, for example, get all windows a way to get references
to all of the existing browser window instances.
So being a static method on the browser window module call get all windows which are locked out.
We're expecting two instances.
Main window and sec window save.
Check the terminal there, get all Windows returns, an array with those two browser window instances.
So pretty simple, we can also instead get the window currently in focus or buy a specific window ID.
And again, a bit further down now, in the instance property section, we see that getting a window
ID is as simple as checking the ID property of a window instance.
So for example, main window dot I.D. will be the ID for our main app window.
With finally the browser window instance methods, these all being very similar to the corresponding
app instance methods, but specific to a browser window instance, close focus, blur, checking if
a window is visible and so on.
Let's see a basic example.
I'll comment about all of this.
Listen on SEC window or when it's closed.
Call on the main window instance, maximize meaning when SEC window is closed.
This event fires which then caused the main windows maximize method save.
These two windows load as normal, we can switch, focus and so on, but the second I close the window,
my window is maximized.
So whilst an arbitrary example, you can see how using a combination of browser window events and methods,
multiple windows essentially become part of one app, having linked interactions and behaviors as before,
we have many of these instant methods, things like checking of an app is running in full screen mode,
changing the windows, background, color and many more.
I'd encourage you to have a quick look through these just so you're aware of what is available when
we get to the project section will start implementing some more real world use cases for these.